/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tenorclient;

import TransportLayer.IDataTransportable;
import TransportLayer.SocketClient;
import TransportLayer.SrtpException;
import cryptography.BasicKeyGenerator;
import cryptography.BasicSaltGenerator;
import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.util.logging.Level;
import java.util.logging.Logger;
import srtp.SceneSrtp;

/**
 *
 * @author Tomasz Nowak
 */
public class ConversationListener
{
	private ServerSocket serverSocket;

	public ConversationListener( InetAddress addres, int port, int backlog )
	{
		try
		{
			serverSocket = new ServerSocket(port, backlog, addres);
		}
		catch ( IOException ex )
		{
			Logger.getLogger(ConversationListener.class.getName()).log(Level.SEVERE,
																																 null, ex);
		}
	}

	public ServerSocket getServerSocket()
	{
		return serverSocket;
	}

	public IDataTransportable acceptConnection() throws IOException, SrtpException
	{
		return new SocketClient(serverSocket.accept(), new SceneSrtp(new BasicSaltGenerator(), new BasicKeyGenerator()));
	}
}
